// pages/order/detail/order-detail.js

import request from "../../../utils/request.js";
import local from "../../../utils/local";


Page({

  /**
   * 页面的初始数据
   */
  data: {
    appid: 'wx15a7538fa77ddfc0',
    surName: '',
    typeData: {},
    priceData: {},
    orderData: {},
    overData: {},
    numberData: {},
    codePriceData: {},
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    const memberID = local.getLocal('memberID');
    let dataStr = decodeURIComponent(options.data)
    let params = JSON.parse(dataStr)
    const tempSurName = params.code
    this.setData({
      memberID: memberID,
      surName: tempSurName
    })
    this.getPaipanitemsservice()
  },


  getPaipanitemsservice() {
   
    const that = this;
    let userInfoDic = {
      "user": this.data.appid,
      "eventCode": "316"
    }
    let paiPanItemsStuctDic = {
      "surName": this.data.surName,
      "memberID": this.data.memberID,
    }
    let dic = {
      userInfo: userInfoDic,
      paiPanItemsStuct: paiPanItemsStuctDic,
    }
    console.log(dic)
    request.get('/paipanitemsservice',{param: dic}).then((res) => {
      console.log(res)
      const returnCode = res.RETURN
      if (returnCode == 1) {
        const object = res.ORDER_INFO
        let tempTypeData = {
          'title': '会员类型: ', 
          'subtitle': object.memberType,
        }
        let tempPriceData = {
          'title': '订单金额: ', 
          'subtitle': object.payAmo + '元',
        }
        let tempOrderData = {
          'title': '下单日期: ', 
          'subtitle': object.createTime,
        }
        let tempOverData = {
          'title': '过期日期: ', 
          'subtitle': object.overTime,
        }
        let tempNumberData = {
          'title': '单据号: ', 
          'subtitle': object.paiPanOrderSheetCode,
        }
        let tempCodePriceData = {
          'title': '交易码: ', 
          'subtitle': object.transID,
        }
        that.setData({
          typeData: tempTypeData,
          priceData: tempPriceData,
          orderData: tempOrderData,
          overData: tempOverData,
          numberData: tempNumberData,
          codePriceData: tempCodePriceData,
        })
      }else {
        const msg = res.MSG
        toast.showToast(msg)
      }
    })
  },
  
})